import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function(location) {
  return originalPush.call(this,location).catch(err=>{})
};
Vue.use(VueRouter)

const routes = [
  
  {
    path: '/product_details',
    name: 'Product_details',
    component: () => import('../views/Product_details.vue'),
  },
  {
    path: '/me',
    name: 'Me',
    component: () => import('../views/Me.vue'),
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue'),
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/car_list',
    name: 'Car_list',
    component: () => import('../views/Car_list.vue'),
  },
  {
    path: '/test',
    name: 'Test',
    component: () => import('../testing/01_test.vue')
  },
  {
    path: '/',
    redirect: '/home',
    
   
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children:[
      {
        path: '/home/searchpopup',
        name: 'SearchPopup',
        component: () => import('../views/SearchPopup.vue'),
      },
    ]
  },

  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
